#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
using namespace std;

#define MAX_N 200000
std::pair<int, int> activities[MAX_N + 5];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> activities[i].first >> activities[i].second;
    }
    sort(activities, activities + n);
    int ret = 0;
    int r = activities[0].second;
    for(int i = 1; i < n; i++)
    {
        if(r > activities[i].first)
        {
            //有重叠
            r = min(activities[i].second, r);
        }
        else
        {
            r = activities[i].second;
            ret += 1;
        }
    }
    cout << ret + 1;
    return 0;
}